package com.cn.qgx428.lazydiary.mWidget

import android.content.Context
import android.util.AttributeSet
import android.view.View
import android.widget.RelativeLayout

/**
 * Created by qinguanxiong on 2018/1/14.
 */
class SquareLayout : RelativeLayout {

    constructor(context: Context?) : super(context)

    constructor(context: Context?, attrs:AttributeSet?) : super(context,attrs)

    constructor(context: Context?, attrs:AttributeSet?, defStyle:Int) : super(context, attrs, defStyle)


    override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
        setMeasuredDimension(View.getDefaultSize(0,widthMeasureSpec),
                View.getDefaultSize(0, heightMeasureSpec))
        val width = measuredWidth
        var realWidth = MeasureSpec.makeMeasureSpec(width,MeasureSpec.EXACTLY)
        super.onMeasure(realWidth, realWidth)
    }
}